let t = require;
let e = module
let o = e.exports;
o.default = e.exports;

'use strict';
console.log("start");
var n =
    (this && this.__decorate) ||
    function (t, e, o, n) {
        var i,
            r = arguments.length,
            a =
                r < 3 ?
                    e :
                    null === n ?
                        (n = Object.getOwnPropertyDescriptor(e, o)) :
                        n;
        if (
            'object' ==
            (typeof Reflect === 'undefined' ?
                'undefined' :
                typeof (Reflect)) &&
            'function' == typeof Reflect.decorate
        )
            a = Reflect.decorate(t, e, o, n);
        else
            for (var s = t.length - 1; s >= 0; s--) {
                (i = t[s]) &&
                    (a = (r < 3 ? i(a) : r > 3 ? i(e, o, a) : i(e, o)) || a);
            }
        return r > 3 && a && Object.defineProperty(e, o, a), a;
    };
Object.defineProperty(o, '__esModule', {
    value: !0
}),
    (o.ItemRefreshMrg = void 0);
var i = t('MathUtils'),
    r = t('SoldierItemCfg'),
    a = t('SoldierItemInfo'),
    s = t('MergeMrg'),
    c = t('CivilizationMrg'),
    l = cc._decorator,
    u = l.ccclass,
    h =
        (l.property,
            (function () {
                function t() {
                    this.reset();
                }
                var e;
                return (
                    (e = t),
                    Object.defineProperty(t, 'ins', {
                        get: function get() {
                            return null == e._ins && (e._ins = new e()), this._ins;
                        },
                        enumerable: !1,
                        configurable: !0
                    }),
                    (t.prototype.reset = function () {
                        (this._refreshTimes = 0),
                            (this._curTimesAry = i.default.randomAverage(
                                e.VIDEO_TIMES_ARY
                            ));
                    }),
                    (t.prototype.incTimes = function () {
                        this._refreshTimes += 1;
                    }),
                    (t.prototype.getVideoSoldierItem = function (t) {
                        // 检查刷新次数是否超过阈值
                        if (this._refreshTimes > this._curTimesAry[this._curTimesAry.length - 1]) {
                            // 若刷新次数为奇数，返回 null
                            if (this._refreshTimes % 2 === 1) {
                                return null;
                            }
                        } else {
                            // 使用 Set 优化查找性能
                            const refreshTimesSet = new Set(this._curTimesAry);
                            if (!refreshTimesSet.has(this._refreshTimes)) {
                                return null;
                            }
                        }

                        // 获取第一个物品等级
                        const firstItemLevel = c.CivilizationMrg.ins.data.itemLevels[0];
                        // 生成复合物品
                        const compoundItem = this.getCompoundItem(firstItemLevel + 3);

                        // 根据复合物品是否为空返回不同结果
                        if (compoundItem === null) {
                            const randomValue = i.default.randomInt(100);
                            return randomValue < 20
                                ? this.getMaxLevelItem(t, firstItemLevel + 3)
                                : this.getMaxLevelItem(t, firstItemLevel + 2);
                        }

                        return compoundItem;
                    }),
                    (t.prototype.getMaxLevelItem = function (t, e) {
                        var o = i.default.weightsRandom(t.itemTypes) + 1,
                            n = r.SoldierItemCfg.ins.getDataByTypeLevel(o, e);
                        return new a.SoldierItemInfo(n.id, !1);
                    }),
                    (t.prototype.getCompoundItem = function (t) {
                        var e = s.MergeMrg.getCanMergeLeastLevelItems(t);
                        if (0 == e.length) return null;
                        if (1 == e.length) return new a.SoldierItemInfo(e[0].id, !0);
                        var o = i.default.randomAverage(e);
                        return new a.SoldierItemInfo(o.id, !1);
                    }),
                    (t.VIDEO_TIMES_ARY = [
                        [3, 5, 8, 10, 13, 15, 18, 20, 23, 25, 28, 30, 33, 35, 38, 40],
                        [4, 7, 9, 12, 14, 17, 19, 22, 24, 27, 29, 32, 34, 37, 39]
                    ]),
                    (e = n([u('ItemRefreshMrg')], t))
                );
            })());
(o.ItemRefreshMrg = h), console.log("end");
module.exports = e.exports;